'use strict'
var config = require('./config')

function User(name){
    this.name = name
    //用户在哪层
    this.wheel = null
    //用户在那层的哪个位置
    this.index = null
    //本轮投票
    this.vote = 0
    //投票记录
    this.votes = []
    //开洞权
    this.holes = 0

}

//投票
User.prototype.setVote = function(num){
    this.vote = num
}

User.prototype.addHole = function(num = 1){
    this.holes += num
}

//开洞
User.prototype.hole = function(num){
    if(this.holes < num) num = this.holes
    if(num <= 0) return 0
    this.wheel.openHole(num)
    this.holes -= num
    return num
}


User.prototype.holePre = function(num){
    if(!this.wheel.pre) return 0
    if(this.holes < num) num = this.holes
    if(num <= 0) return 0
    num = 1
    this.wheel.pre.openHole(num)
    this.holes -= num
    return num
}
module.exports = User